package com.mofe.zxy.config;

import com.mofe.zxy.domain.AdminUserDetail;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class MyAccessTokenConverter extends DefaultAccessTokenConverter {


    @Override
    public Map<String, ?> convertAccessToken(OAuth2AccessToken token, OAuth2Authentication authentication) {


        Map<String, Object> stringMap = (Map<String, Object>) super.convertAccessToken(token, authentication);

        AdminUserDetail details = (AdminUserDetail)authentication.getUserAuthentication().getPrincipal();
        stringMap.put("adminId",details.getAdminId());
        return stringMap;
    }
}
